package com.service.admin.borrow.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.github.pagehelper.Page;
import com.github.pagehelper.PageHelper;
import com.service.admin.borrow.controller.req.SysBorrowPageRequest;
import com.service.admin.borrow.service.SysBorrowConfigService;
import com.service.core.rest.response.CommonPageRep;
import com.service.dao.mapper.SysBorrowConfigMapper;
import com.service.dao.model.SysBorrowConfig;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
@Slf4j
public class SysBorrowConfigServiceImpl extends ServiceImpl<SysBorrowConfigMapper, SysBorrowConfig>
	implements SysBorrowConfigService {

	@Autowired
	private SysBorrowConfigMapper borrowConfigMapper;

	/**
	 * 分页查询借贷系统配置
	 *
	 * @param req
	 * @return
	 */
	@Override
	public CommonPageRep<SysBorrowConfig> pageLastBorrowConfig(SysBorrowPageRequest req) {
		Page<SysBorrowConfig> page = PageHelper.startPage(req.getPageNo(), req.getPageSize());
		LambdaQueryWrapper<SysBorrowConfig> queryWrapper = new LambdaQueryWrapper<>();
		queryWrapper.orderByDesc(SysBorrowConfig::getCreateTime);
		List<SysBorrowConfig> list = borrowConfigMapper.selectList(queryWrapper);
		return CommonPageRep.buildResultRep(page,list);
	}
}
